package com.sure.supermarketserver.sell.cash.dao;



import com.sure.supermarketserver.sell.cash.model.pojo.Goods;
import com.sure.supermarketserver.sell.cash.model.to.CashEndPrice;
import com.sure.supermarketserver.sell.cash.model.to.CashOrder;
import com.sure.supermarketserver.sell.cash.model.to.CashOrderClient;
import com.sure.supermarketserver.sell.cash.model.to.CashOrderInfo;
import com.sure.supermarketserver.sell.cash.model.vo.CashClientVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Lei
 * @create 2021-07-21 13:06
 */
public interface CashDao {

    /**
     * @Author Lei
     * @Description 得到goods表里面的信息，根据goodsId
     * @Date 20:14 2021/7/21
     * @Param [goodsId]
     * @return com.sure.supermarketserver.sell.cash.model.pojo.Goods
     **/
    @Select("select go_id,ca_id,br_id,go_num,go_price,go_discount from goods where go_id=#{goodsId} ")
    Goods getAGoodsById(String goodsId);

    /**
     * @Author Lei
     * @Description order_detail获取记录数
     * @Date 20:14 2021/7/21
     * @Param []
     * @return int
     **/
    @Select("select count(*) from order_detail")
    int getOrderDetailCount();

    /**
     * @Author Lei
     * @Description order_information的记录数
     * @Date 20:15 2021/7/21
     * @Param []
     * @return int
     **/
    @Select("select count(*) from order_information")
    int getOrderInformationCount();

    /**
     * @Author Lei
     * @Description 将添加order_detail的一条记录
     * @Date 20:15 2021/7/21
     * @Param [cashOrder]
     * @return int
     **/
    @Insert("insert into order_detail values(#{od_number},#{od_price},#{od_id},#{or_id},#{br_id},#{go_id})")
    int insertIntoOrderDetail(CashOrder cashOrder);

    /**
     * @Author Lei
     * @Description 将添加order_information的一条记录
     * @Date 20:15 2021/7/21
     * @Param [cashOrderInfo]
     * @return int
     **/
<<<<<<< HEAD
    @Insert("insert into order_information(or_id,or_sum,or_time) values(#{or_id},#{or_sum},now())")
=======
    @Insert("insert into order_information(or_id,or_sum) values(#{or_id},#{or_sum})")
>>>>>>> 5f10f6198a25dcc9a1d966785717ca9d10c0d8ba
    int insertIntoOrderInfo(CashOrderInfo cashOrderInfo);
    
    /**
     * @Author Lei
     * @Description 得到ca_name 通过ca_id
     * @Date 20:16 2021/7/21
     * @Param [ca_id]
     * @return java.lang.String
     **/
    @Select("select ca_name from cargo where ca_id=#{ca_id}")
    String getCaName(String ca_id);


    /**
     * @Author Lei
     * @Description 通过or_id来获取这个or_id,or_sum信息
     * @Date 20:16 2021/7/21
     * @Param [or_id]
     * @return com.sure.supermarketserver.sell.cash.model.to.CashOrderInfo
     **/
    @Select("select or_id,or_sum from order_information where or_id = #{or_id}")
    CashOrderInfo getOrderInfoByOrId(String or_id);


    /**
     * @Author Lei
     * @Description 最后的总费用
     * @Date 20:17 2021/7/21
     * @Param [cashEndPrice]
     * @return int
     **/
<<<<<<< HEAD
    @Update("update order_information set or_sum = #{or_sum},or_time = now(),st_id=#{st_id} where or_id = #{or_id}")
=======
    @Update("update order_information set or_sum = #{or_sum} where or_id = #{or_id}")
>>>>>>> 5f10f6198a25dcc9a1d966785717ca9d10c0d8ba
    int updateOrderInfoEndPrice(CashEndPrice cashEndPrice);

    /**
     * @Author Lei
     * @Description 更新客户的积分cl_credit
     * @Date 20:17 2021/7/21
     * @Param [cashOrderClient]
     * @return int
     **/
    @Update("update client set cl_credit = #{sum} where cl_id =#{cl_id}")
    int addScore(CashOrderClient cashOrderClient);


    /**
     * @Author Lei
     * @Description 获取到这个cl_id,cl_credit通过cl_id
     * @Date 20:17 2021/7/21
     * @Param [cl_id]
     * @return com.sure.supermarketserver.sell.cash.model.vo.CashClientVo
     **/
    @Select("select cl_id,cl_credit from client where cl_id=#{cl_id}")
    CashClientVo getByClId(String cl_id);


<<<<<<< HEAD
    @Update("update goods set go_num=go_num-1 where go_id=#{go_id}")
    void delgoods(CashOrder cashOrder);
=======
>>>>>>> 5f10f6198a25dcc9a1d966785717ca9d10c0d8ba
}
